package Practice7_XML;

import Utils.basicDataTypes.BasicDataTypesUtils;
import Utils.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

public class P1_XML {
    /**
     * 使用DOM
     */
    @Test
    public void test01() throws ParserConfigurationException, IOException, SAXException {
        InputStream is = IOUtils.file2InputStream("src/test/resources/test.xml");
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(is);
        BasicDataTypesUtils.printNode(doc,0);
    }

    @Test
    public void test02() {
        File file = new File("src/main/resources/test.xml");
        System.out.println(file.exists());
        System.out.println(file.isFile());
    }
}
